home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games 1996 December / Amiga Games 1996 #12.iso / rexx / arcdir.dopus5 next >
Text File  |  1996-08-11  |  23KB  |  844 lines

  1. /*
  2.   $VER: ArcDir.dopus5 1.0 (11.8.96)
  3.   Written by Edmund Vermeulen (edmundv@grafix.xs4all.nl).
  4.  
  5.   ARexx script for Directory Opus 5 to show the contents of an LhA or LZX
  6.   archive in an Opus lister and operate on the files and directories inside
  7.   the archive as if it is a normal directory.
  8.  
  9.   Function : ARexx      DOpus5:ARexx/ArcDir.dopus5 Browse {Qp} {f} {Ql}
  10.   Flags : Run asynchronously
  11. */
  12.  
  13. parse arg cmd ' ' portname ' "' arcfile '" ' handle ' ' arcsubdir
  14.  
  15. address value portname
  16. options results
  17. options failat 21
  18. signal on syntax
  19. signal on halt
  20. signal on break_c
  21. lf='0a'x
  22.  
  23. dopus getfiletype '"'arcfile'"' id
  24. arctype=result
  25. if arctype~='LHA' & arctype~='LZX' then
  26.    exit
  27.  
  28. if ~show('l','rexxsupport.library') then
  29.    call addlib('rexxsupport.library',0,-30)
  30.  
  31. if exists('LIBS:locale.library') then do
  32.    if ~show(l,'locale.library') then
  33.       call addlib('locale.library',0,-30)
  34.    catalog=opencatalog('ArcDir.catalog','english',0)
  35.    end
  36. else
  37.    catalog=0
  38.  
  39. dopus version
  40. newopus=result~='RESULT' & translate(result,'.',' ')>=5.1215
  41.  
  42. if upper(cmd)='BROWSE' | handle=0 then do
  43.    lister new
  44.    handle=result
  45.    lister set handle source
  46.    end
  47. else
  48.    lister empty handle
  49.  
  50. call arclist
  51.  
  52.  
  53. /* Attach a handler to the lister and wait for an event to happen. */
  54.  
  55. handlername='ArcDir'handle
  56. lister set handle handler handlername quotes
  57. call openport(handlername)
  58.  
  59. viewcommands='Read HexRead Show Play'  /* you may add other Opus commands if you wish */
  60. notsupported='CopyAs Move MoveAs Rename Comment Protect'
  61. traps='Copy Delete MakeDir Parent Root ScanDir' viewcommands notsupported
  62. do while traps~=''
  63.    parse var traps trapcommand traps
  64.    dopus addtrap trapcommand handlername
  65.    end
  66.  
  67. thishandle=handle
  68. lister set handle busy off
  69.  
  70. do until event='inactive'
  71.    if waitpkt(handlername) then do
  72.  
  73.       packet=getpkt(handlername)
  74.       if packet~='00000000'x then do
  75.  
  76.          event=getarg(packet,0)
  77.          handle=getarg(packet,1)
  78.          namestr=getarg(packet,2)
  79.          user=getarg(packet,3)
  80.          pathstr=getarg(packet,4)
  81.          qualifier=getarg(packet,6)
  82.          deststr=getarg(packet,7)
  83.  
  84.          if newopus then
  85.             lister wait thishandle quick
  86.          else do
  87.             lister query thishandle busy
  88.             if result=1 then
  89.                call delay(10)
  90.             end
  91.  
  92.          select
  93.             when event='doubleclick' then do
  94.                if left(namestr,1)='"' then
  95.                   parse var namestr '"' namestr '"'
  96.                if namestr='' then
  97.                   fileinfo.type=1
  98.                else
  99.                   lister query handle entry '"'namestr'"' stem fileinfo.
  100.                if fileinfo.type>0 then do  /* it's a dir */
  101.                   if qualifier='shift' then do
  102.                      lister new
  103.                      newhandle=result
  104.                      address command 'Copy >NIL: T:ArcDir.list'handle 'T:ArcDir.list'newhandle
  105.                      lister set newhandle source
  106.                      address command 'Run >NIL: <NIL: RX DOpus5:ARexx/ArcDir.dopus5 GETDIR' portname '"'arcfile'"' newhandle arcsubdir||namestr'/'
  107.                      end
  108.                   else do
  109.                      arcsubdir=arcsubdir||namestr'/'
  110.                      call arclist
  111.                      end
  112.                   end
  113.                else
  114.                   call viewsingle
  115.                end
  116.  
  117.             when event='reread' | event='ScanDir' then do
  118.                call delete('T:ArcDir.list'handle)
  119.                call arclist
  120.                end
  121.  
  122.             when event='path' then
  123.                call dopath
  124.  
  125.             when event='drop' then do
  126.                parse var namestr '"' droppath '"'
  127.                if pos(right(droppath,1),'/:')>0 then  /* disk or left-out drawer */
  128.                   lister read handle '"'droppath'"' force
  129.                else do
  130.                   parse var namestr '"' dropfile '"'
  131.                   if pos(':',dropfile)=0 then do
  132.                      lister query user path
  133.                      dropfile=result||dropfile
  134.                      end
  135.                   dopus getfiletype '"'dropfile'"' id
  136.                   if result='LHA' | result='LZX' then do
  137.                      arctype=result
  138.                      arcfile=dropfile
  139.                      arcsubdir=''
  140.                      call delete('T:ArcDir.list'handle)
  141.                      call arclist
  142.                      end
  143.                   else do
  144.                      allents=namestr
  145.                      call getall
  146.                      otherhandle=user
  147.                      call arcadd
  148.                      end
  149.                   end
  150.                end
  151.  
  152.             when event='dropfrom' then
  153.                if qualifier='shift' then do
  154.                   parse var namestr '"' namestr '"'
  155.                   lister query handle entry '"'namestr'"' stem fileinfo.
  156.                   if fileinfo.type>0 then do
  157.                      address command 'Copy >NIL: T:ArcDir.list'handle 'T:ArcDir.list'user
  158.                      address command 'Run >NIL: <NIL: RX DOpus5:ARexx/ArcDir.dopus5 GETDIR' portname '"'arcfile'"' user arcsubdir||namestr'/'
  159.                      end
  160.                   end
  161.                else do
  162.                   allents=namestr
  163.                   call getall
  164.                   otherhandle=user
  165.                   call arcextract
  166.                   end
  167.  
  168.             when upper(event)='PARENT' | upper(event)='ROOT' then
  169.                call doparentroot
  170.  
  171.             when event='Delete' then
  172.                call dodelete
  173.  
  174.             when event='MakeDir' then
  175.                call domakedir
  176.  
  177.             when event='Copy' then do
  178.                lister query handle selentries
  179.                allents=result
  180.                call getall
  181.                if handle=thishandle then do
  182.                   otherhandle=user
  183.                   call arcextract
  184.                   end
  185.                else do
  186.                   otherhandle=handle
  187.                   handle=user
  188.                   call arcadd
  189.                   end
  190.                end   
  191.  
  192.             when pos(event,viewcommands)>0 then do
  193.                lister query handle firstsel
  194.                parse var result '"' namestr '"'
  195.                lister select handle '"'namestr'"' off
  196.                lister refresh handle
  197.                call viewsingle
  198.                end
  199.  
  200.             when pos(event,notsupported)>0 then do
  201.                lister set handle busy on
  202.                call displayerror(getcatstr(23,'Command not supported in ArcDir.'))
  203.                lister set handle busy off
  204.                end
  205.  
  206.             otherwise
  207.                nop
  208.             end
  209.  
  210.          lister set handle busy off
  211.          call reply(packet,0)
  212.          end
  213.       end
  214.    end
  215.  
  216. call delete('T:ArcDir.list'handle)
  217. call closeport(handlername)
  218. if catalog~=0 then
  219.    call closecatalog(catalog)
  220. exit
  221.  
  222.  
  223. doparentroot:
  224.  
  225.    if arcsubdir='' then do
  226.       cuthere=lastpos('/',arcfile)
  227.       if cuthere=0 | upper(event)='ROOT' then
  228.          cuthere=pos(':',arcfile)
  229.       normaldir=left(arcfile,cuthere)
  230.       if qualifier='shift' then do
  231.          lister new normaldir
  232.          newhandle=result
  233.          lister wait newhandle
  234.          lister set newhandle source
  235.          end
  236.       else do
  237.          lister set handle title
  238.          lister read handle normaldir
  239.          end
  240.       end
  241.    else do
  242.       if upper(event)='ROOT' then
  243.          newsubdir=''
  244.       else do
  245.          cuthere=lastpos('/',left(arcsubdir,length(arcsubdir)-1))
  246.          newsubdir=left(arcsubdir,cuthere)
  247.          end
  248.       if qualifier='shift' then do
  249.          lister new
  250.          newhandle=result
  251.          address command 'Copy >NIL: T:ArcDir.list'handle 'T:ArcDir.list'newhandle
  252.          lister set newhandle source
  253.          address command 'Run >NIL: <NIL: RX DOpus5:ARexx/ArcDir.dopus5 GETDIR' portname '"'arcfile'"' newhandle newsubdir
  254.          end
  255.       else do
  256.          arcsubdir=newsubdir
  257.          call arclist
  258.          end
  259.       end
  260.    return
  261.  
  262.  
  263. dopath:
  264.  
  265.    if pos(right(namestr,1),'/:')=0 then
  266.       namestr=namestr'/'
  267.    if left(namestr,length(arcfile))=arcfile then do
  268.       if namestr=arcfile'/'arcsubdir then
  269.          call delete('T:ArcDir.list'handle)
  270.       else
  271.          arcsubdir=substr(namestr,length(arcfile)+2)
  272.       call arclist
  273.       end
  274.    else do
  275.       cuthere=pos('.LHA/',upper(namestr))
  276.       if cuthere=0 then
  277.          cuthere=pos('.LZH/',upper(namestr))
  278.       if cuthere>0 then
  279.          arctype='LHA'
  280.       else do
  281.          cuthere=pos('.LZX/',upper(namestr))
  282.          if cuthere>0 then
  283.             arctype='LZX'
  284.          end
  285.       if cuthere>0 then do
  286.          call delete('T:ArcDir.list'handle)
  287.          arcfile=left(namestr,cuthere+3)
  288.          arcsubdir=substr(namestr,cuthere+5)
  289.          call arclist
  290.          end
  291.       else do
  292.          lister read handle '"'namestr'"' force
  293.          end
  294.       end
  295.    return
  296.  
  297.  
  298. dodelete:
  299.  
  300.    lister set handle busy on
  301.    lister query handle selentries
  302.    allents=result
  303.    call getall
  304.    if entries=0 then
  305.       return
  306.  
  307.    lister query handle numselfiles
  308.    nfiles=result
  309.    lister query handle numseldirs
  310.    ndirs=result
  311.    call dorequest('"'getcatstr(5,'Warning: you cannot get back'lf||,
  312.       'what you delete! OK to delete:'lf||lf'%s file(s) and'lf||,
  313.       '%s drawer(s) (and their contents)?',nfiles,ndirs)'"',
  314.       getcatstr(6,'Proceed|Cancel'))
  315.    if ~rc then
  316.       return
  317.  
  318.    lister set handle title getcatstr(7,'Deleting from archive...')
  319.    lister refresh handle full
  320.  
  321.    select 
  322.       when arctype='LHA' then do
  323.          call open('actionfile','T:actionfile'handle,'w')
  324.          do i=1 to entries
  325.             if type.i>0 then
  326.                wild='/#?'
  327.             else
  328.                wild=''
  329.             call writeln('actionfile','"'patch(arcsubdir||name.i,"'")||wild'"')
  330.             end
  331.          call close('actionfile')
  332.          address command 'LhA d -q -X -Qp -Qo "'patch(arcfile)'" @T:actionfile'handle
  333.          problem=rc>0
  334.          address command 'Delete >NIL: T:LhA_ArcWork.#? QUIET'
  335.          problem=problem | rc=0
  336.          call delete('T:actionfile'handle)
  337.          end
  338.       when arctype='LZX' then do
  339.          lzxcmd='LZX d -q -X0 --' lzxkludge(patch(arcfile))
  340.          linelen=0
  341.          n=0
  342.          do i=1 to entries
  343.             if type.i>0 then
  344.                dothis=lzxkludge(patch(arcsubdir||name.i,'[')'/#?')
  345.             else
  346.                dothis=lzxkludge(patch(arcsubdir||name.i))
  347.             linelen=linelen+length(dothis)+1
  348.             if i=1 | linelen>255 then do
  349.                n=n+1
  350.                dothese.n=dothis
  351.                linelen=length(lzxcmd)+length(dothis)+1
  352.                end
  353.             else
  354.                dothese.n=dothese.n dothis
  355.             end
  356.          do i=1 to n
  357.             address command lzxcmd dothese.i
  358.             problem=rc>0
  359.             if problem then
  360.                leave
  361.             end
  362.          end
  363.       end
  364.  
  365.    if problem then
  366.       call displayerror(getcatstr(8,'Error while deleting from archive.'))
  367.    else do
  368.       call delete('T:ArcDir.list'handle)
  369.       do i=1 to entries
  370.          if name.i='' then do
  371.             lister query handle separate
  372.             if result='filesfirst' then do
  373.                lister query handle numfiles
  374.                entryno=result
  375.                end
  376.             else
  377.                entryno=0
  378.             lister remove handle '#'entryno
  379.             end
  380.          else
  381.             lister remove handle '"'name.i'"'
  382.          end
  383.       end
  384.  
  385.    lister set handle title 'ArcDir:' arcname
  386.    lister refresh handle full
  387.    return
  388.  
  389.  
  390. domakedir:
  391.  
  392.    lister set handle busy on
  393.    dopus getstring '"'getcatstr(15,'Enter directory name')'" 31 ""' getcatstr(16,'OK|Cancel')
  394.    dirtomake=result
  395.    if dirtomake=='' | dirtomake='RESULT' then
  396.       return
  397.  
  398.    now=date('i')*86400+time('s')
  399.    call createdirs(dirtomake'/')
  400.  
  401.    select
  402.       when arctype='LHA' then
  403.          address command 'LhA a -q -e -r -X -Qo "'patch(arcfile)'" T:ArcDir'handle'/' '"'patch(arcsubdir||dirtomake,"'")'"'
  404.       when arctype='LZX' then do
  405.          oldcurrent=pragma('d')
  406.          call pragma('d','T:ArcDir'handle)
  407.          address command 'LZX a -q -e -r -X0 --' lzxkludge(patch(arcfile)) lzxkludge(patch(arcsubdir||dirtomake))
  408.          call pragma('d',oldcurrent)
  409.          end
  410.       end
  411.  
  412.    if rc>0 then
  413.       call displayerror(getcatstr(13,'Error while adding to archive.'))
  414.    else do
  415.       lister add handle '"'dirtomake'" -1 1' now '----rwed'
  416.       lister refresh handle
  417.       end
  418.  
  419.    address command 'Delete >NIL: T:ArcDir'handle 'ALL QUIET'
  420.    call delete('T:ArcDir.list'handle)
  421.    return
  422.  
  423.  
  424. createdirs:
  425.  
  426.    parse arg subdir
  427.    dirstocreate='T:ArcDir'handle'/'arcsubdir||subdir
  428.    here=0
  429.    do until here=0
  430.       here=pos('/',dirstocreate,here+1)
  431.       if here>0 then
  432.          call makedir(left(dirstocreate,here-1))
  433.       end
  434.    return
  435.  
  436.  
  437. arclist:
  438.  
  439.    lister set handle busy on
  440.    lister clear handle
  441.    lister set handle title getcatstr(1,'Listing archive...')
  442.    lister set handle path arcfile'/'arcsubdir
  443.    lister refresh handle full
  444.  
  445.    if ~exists(arcfile) then do
  446.       call displayerror(getcatstr(22,'Error: archive not found'))
  447.       return
  448.       end
  449.  
  450.    if ~exists('T:ArcDir.list'handle) then do
  451.       select
  452.          when arctype='LHA' then
  453.             address command 'LhA >T:ArcDir.list'handle 'vv -N -X -Qw -Qo "'arcfile'"'
  454.          when arctype='LZX' then
  455.             address command 'LZX >T:ArcDir.list'handle 'v -X0 --' lzxkludge(patch(arcfile))
  456.          end
  457.       if rc>0 then
  458.          call displayerror(getcatstr(2,'Error while listing archive.'))
  459.       end
  460.  
  461.    oldcurrent=pragma('d')
  462.    call pragma('d','DOpus5:C')
  463.    address command 'ArcDirList >T:ArcDir.list'handle'@ T:ArcDir.list'handle '"'patchstar(arcsubdir)'"'
  464.    call pragma('d',oldcurrent)
  465.  
  466.    if ~open('tempfile','T:ArcDir.list'handle'@','r') then do
  467.       call displayerror(getcatstr(24,'ArcDirList not found!'))
  468.       return
  469.       end
  470.    thisline=readln('tempfile')
  471.    do while thisline~=''
  472.       lister add handle thisline
  473.       thisline=readln('tempfile')
  474.       end
  475.    call close('tempfile')
  476.    call delete('T:ArcDir.list'handle'@')
  477.  
  478.    cuthere=lastpos('/',arcfile)
  479.    if cuthere=0 then
  480.       cuthere=lastpos(':',arcfile)
  481.    arcname=substr(arcfile,cuthere+1)
  482.    lister set handle title 'ArcDir:' arcname
  483.    lister refresh handle full
  484.    return
  485.  
  486.  
  487. arcextract:
  488.  
  489.    lister set handle busy on
  490.    if otherhandle=0 then
  491.       if newopus then
  492.          winpath=deststr
  493.       else do
  494.          call displayerror(getcatstr(9,'No destination selected!'))
  495.          return
  496.          end
  497.    else do
  498.       if checkhandler() then
  499.          return
  500.       lister set otherhandle busy on
  501.       lister query otherhandle path
  502.       winpath=result
  503.       end
  504.  
  505.    lister query handle numdirs
  506.    anydirs=result>0
  507.    mustmove=anydirs & arcsubdir~==''
  508.    if mustmove then do
  509.       destpath=winpath'ArcDir'handle
  510.       call makedir(destpath)
  511.       destpath=destpath'/'
  512.       end
  513.    else
  514.       destpath=winpath
  515.  
  516.    lister set handle title getcatstr(10,'Extracting from archive...')
  517.    lister refresh handle full
  518.  
  519.    select
  520.       when arctype='LHA' then do
  521.          call open('actionfile','T:actionfile'handle,'w')
  522.          do i=1 to entries
  523.             if type.i>0 then
  524.                wild='/#?'
  525.             else
  526.                wild=''
  527.             call writeln('actionfile','"'patch(arcsubdir||name.i,"'")||wild'"')
  528.             end
  529.          call close('actionfile')
  530.  
  531.          if anydirs then
  532.             cmd='x'
  533.          else
  534.             cmd='e -x2'
  535.          address command 'LhA' cmd '-q -a -C0 -X -Qo "'patch(arcfile)'" "'destpath'" @T:actionfile'handle
  536.          problem=rc>0
  537.          call delete('T:actionfile'handle)
  538.          end
  539.       when arctype='LZX' then do
  540.          if anydirs then
  541.             cmd='x'
  542.          else
  543.             cmd='e'
  544.          lzxcmd='LZX' cmd '-q -a -C0 -X0 --' lzxkludge(patch(arcfile))
  545.  
  546.          linelen=0
  547.          n=0
  548.          do i=1 to entries
  549.             if type.i>0 then
  550.                dothis=lzxkludge(patch(arcsubdir||name.i,'[')'/#?')
  551.             else
  552.                dothis=lzxkludge(patch(arcsubdir||name.i))
  553.             linelen=linelen+length(dothis)+1
  554.             if i=1 | linelen>255 then do
  555.                n=n+1
  556.                dothese.n=dothis
  557.                linelen=length(lzxcmd)+length(dothis)+1
  558.                end
  559.             else
  560.                dothese.n=dothese.n dothis
  561.             end
  562.  
  563.          oldcurrent=pragma('d')
  564.          call pragma('d',destpath)
  565.          do i=1 to n
  566.             address command lzxcmd dothese.i
  567.             problem=rc>0
  568.             if problem>0 then
  569.                leave
  570.             end
  571.          call pragma('d',oldcurrent)
  572.          end
  573.       end
  574.  
  575.    if problem then
  576.       call displayerror(getcatstr(11,'Error while extracting from archive.'))
  577.    else
  578.       do i=1 to entries
  579.          lister select handle '"'name.i'"' off
  580.          end
  581.  
  582.    lister set handle title 'ArcDir:' arcname
  583.    lister refresh handle full
  584.  
  585.    if mustmove then do
  586.       address command 'DOpus5:C/Move >NIL: "'destpath||arcsubdir'#?" "'winpath'"'
  587.       address command 'Delete >NIL: "'winpath'ArcDir'handle'" ALL QUIET'
  588.       end
  589.  
  590.    if otherhandle~=0 then do
  591.       lister set otherhandle busy off
  592.       lister read otherhandle '"'winpath'"' force
  593.       end
  594.    return
  595.  
  596.  
  597. arcadd:
  598.  
  599.    if checkhandler() then
  600.       return
  601.    lister set handle busy on
  602.    lister set otherhandle busy on
  603.    lister query otherhandle path
  604.    frompath=result
  605.  
  606.    mustcopy=upper(right(src,length(arcsubdir)))~==upper(arcsubdir)
  607.    if mustcopy then do
  608.       homedir='T:ArcDir'handle'/'
  609.       call createdirs
  610.       end
  611.    else
  612.       homedir=left(frompath,length(frompath)-length(arcsubdir))
  613.  
  614.    if mustcopy then
  615.       do i=1 to entries
  616.          lister query otherhandle entry '"'name.i'"' stem fileinfo.
  617.          if fileinfo.type>0 then
  618.             address command 'Copy "'frompath||name.i'" "T:ArcDir'handle'/'arcsubdir||name.i'" ALL CLONE QUIET'
  619.          else
  620.             address command 'Copy "'frompath||name.i'" "T:ArcDir'handle'/'arcsubdir'" CLONE QUIET'
  621.          end
  622.  
  623.    lister set handle title getcatstr(12,'Adding to archive...')
  624.    lister refresh handle full
  625.  
  626.    select
  627.       when arctype='LHA' then do
  628.          call open('actionfile','T:actionfile'handle,'w')
  629.          call writeln('actionfile','"'patch(homedir)'"')
  630.          do i=1 to entries
  631.             call writeln('actionfile','"'patch(arcsubdir||name.i)'"')
  632.             end
  633.          call close('actionfile')
  634.  
  635.          if pos('.LZH/',test)>0 then
  636.             method='-0'
  637.          else
  638.             method=''
  639.          address command 'LhA r' method '-q -e -r -X -Qo "'patch(arcfile)'" @T:actionfile'handle
  640.          problem=rc>0
  641.          call delete('T:actionfile'handle)
  642.          end
  643.       when arctype='LZX' then do
  644.          lzxcmd='LZX u -q -a -e -r -X0 --' lzxkludge(patch(arcfile))
  645.          linelen=0
  646.          n=0
  647.          do i=1 to entries
  648.             if type.i>0 then
  649.                dothis=lzxkludge(patch(arcsubdir||name.i,'[')'/#?')
  650.             else
  651.                dothis=lzxkludge(patch(arcsubdir||name.i))
  652.             linelen=linelen+length(dothis)+1
  653.             if i=1 | linelen>255 then do
  654.                n=n+1
  655.                dothese.n=dothis
  656.                linelen=length(lzxcmd)+length(dothis)+1
  657.                end
  658.             else
  659.                dothese.n=dothese.n dothis
  660.             end
  661.  
  662.          oldcurrent=pragma('d')
  663.          call pragma('d',homedir)
  664.          do i=1 to n
  665.             address command lzxcmd dothese.i
  666.             problem=rc>0
  667.             if problem then
  668.                leave
  669.             end
  670.          call pragma('d',oldcurrent)
  671.          end
  672.       end
  673.  
  674.    if mustcopy then
  675.       address command 'Delete >NIL: T:ArcDir'handle 'ALL QUIET'
  676.  
  677.    if problem then
  678.       call displayerror(getcatstr(13,'Error while adding to archive.'))
  679.    else do
  680.       do i=1 to entries
  681.          lister select otherhandle '"'name.i'"' off
  682.          end
  683.       lister refresh otherhandle
  684.       call delete('T:ArcDir.list'handle)
  685.       call arclist
  686.       end
  687.  
  688.    lister set otherhandle busy off
  689.    return
  690.  
  691.  
  692. viewsingle:
  693.  
  694.    lister set handle busy on
  695.    lister set handle title getcatstr(10,'Extracting from archive...')
  696.    lister refresh handle full
  697.  
  698.    select
  699.       when arctype='LHA' then
  700.          address command 'LhA e -q -x2 -X -Qo "'patch(arcfile)'" T: "'patch(arcsubdir||namestr,"'")'"'
  701.       when arctype='LZX' then
  702.          address command 'LZX e -q -X0 --' lzxkludge(patch(arcfile)) 'T:' lzxkludge(patch(arcsubdir||namestr))
  703.       end
  704.  
  705.    if rc>0 then
  706.       call displayerror(getcatstr(11,'Error while extracting from archive.'))
  707.  
  708.    /* some creative ARexx programming :-) */
  709.    address command 'Run >NIL: <NIL: RX',
  710.       '"address' portname';',
  711.       'thisfile=''T:'namestr''';',
  712.       'command' event '''""''thisfile''""'';',
  713.       'command wait protect name ''""''thisfile''""'' set RWED;',
  714.       'do until ~exists(thisfile) | delete(thisfile);',
  715.          'call delay(200);',
  716.          'end"'
  717.  
  718.    lister set handle title 'ArcDir:' arcname
  719.    lister refresh handle full
  720.    return
  721.  
  722.  
  723. getall:
  724.  
  725.    entries=0
  726.    do while allents~=''
  727.       entries=entries+1
  728.       parse var allents '"' name.entries '"' allents
  729.       if name.entries='' then
  730.          type.entries=1
  731.       else do
  732.          lister query handle entry '"'name.entries'"' stem fileinfo.
  733.          type.entries=fileinfo.type
  734.          end
  735.       end
  736.    return
  737.  
  738.  
  739. patch:  /* patch filenames containing strange characters */
  740.  
  741.    parse arg patched,extra
  742.    strange='*#?|%()~'extra
  743.    if arctype='LHA' then
  744.       strange=strange'[]'
  745.    pos=1
  746.    do until here=0
  747.       here=verify(substr(patched,pos),strange,'m')
  748.       if here>0 then do
  749.          pos=pos+here+1
  750.          patched=insert("'",patched,pos-3)
  751.          end
  752.       end
  753.    if arctype='LHA' & left(patched,1)='@' then
  754.       patched='%'patched
  755.    if arctype='LZX' then
  756.       if length(patched)-lastpos('/',patched)>=30 then
  757.          patched=patched'#?'
  758.    return patched
  759.  
  760.  
  761. patchstar:
  762.  
  763.    parse arg remain
  764.    patched=''
  765.    do until remain=''
  766.       parse var remain before '*' remain
  767.       patched=patched||before
  768.       if remain~=='' then
  769.          patched=patched'**'
  770.       end
  771.    return patched
  772.  
  773.  
  774. lzxkludge:
  775.  
  776.    parse arg string
  777.    if pos(' ',string)>0 then
  778.       do while pos("'*",string)>0
  779.          parse var string fore "'*" aft
  780.          string=fore'?'aft
  781.          end
  782.    if pos('*',string)=0 then
  783.       string='"'string'"'
  784.    return string
  785.  
  786.  
  787. getcatstr:
  788.  
  789.    parse arg msgno,msgstring
  790.    if catalog~=0 then
  791.       msgstring=getcatalogstr(catalog,msgno,msgstring)
  792.    do i=3 to arg()
  793.       parse var msgstring fore '%s' aft
  794.       msgstring=fore||arg(i)||aft
  795.       end
  796.    return msgstring
  797.  
  798.  
  799. checkhandler:
  800.  
  801.    lister query otherhandle handler
  802.    return ~(result='RESULT' | result='')
  803.  
  804.  
  805. syntax:
  806.  
  807.    call displayerror('Syntax Error' rc',' errortext(rc) 'in line' sigl'.')
  808.    lister set thishandle busy off
  809.    lister set otherhandle busy off
  810.    exit
  811.  
  812.  
  813. halt:
  814. break_c:
  815.  
  816.    lister set thishandle handler
  817.    lister clear thishandle
  818.    lister set thishandle path
  819.    lister set thishandle title 'ArcDir.dopus5 halted.'
  820.    lister refresh thishandle full
  821.    lister set thishandle title
  822.    exit
  823.  
  824.  
  825. displayerror:
  826.  
  827.    parse arg message
  828.    lister set handle title message
  829.    lister refresh handle full
  830.    command flash
  831.    call dorequest('"'message'"' getcatstr(4,'OK'))
  832.    lister set handle title 'ArcDir:' arcname
  833.    return
  834.  
  835.  
  836. dorequest:
  837.  
  838.    parse arg reqargs
  839.    if newopus then
  840.       lister request handle reqargs
  841.    else
  842.       dopus request reqargs
  843.    return
  844.